// pages/carDetail/carDetail.js
const app = getApp();
const constant = require('../../constant');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    titlecatId: 0,
    imgTitle: '',
    title: '',
    price: '',
    baseParam: [],
    truckList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      titlecatId: options.id,
      imgTitle: constant.config.host + options.img,
      title: options.title,
      price: options.price
    });
    this.getBaseparam();
    this.getTrucklist();
  },
  getBaseparam() {
    let that = this;
    app.get('Goods/gettruckcatmulinfo', {
      titlecat_id: that.data.titlecatId
    }, function (res) {
      if (res.code == 200 && res.data != '') {
        var data = res.data;
        that.setData({
          baseParam: data
        })
        }
      })
  },
  getTrucklist() {
    let that = this;
    app.get('Goods/gettrucklist', {
      titlecat_id: that.data.titlecatId
    }, function (res) {
      if (res.code == 200 && res.data.data_list.length > 0) {
        var data = res.data.data_list;
        that.setData({
          truckList: data
        })
      }
    })
  },
  //咨询底价跳转
  toEnquiry: function (e) {
    var goods_id = e.dataset.currentTarget.id;
    var paramstr = '?goods_id=' + this.data.goods_id;
    wx.navigateTo({
      url: '../enquiry/enquiry' + paramstr
    })
  },
  //车型详情跳转
  toCarDetail: function (event) {
    var goods_id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../carDetail/carDetail?goods_id='+goods_id
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})